package com.blockchain.front.servlets.trading.ajax;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.framework.service.ServiceSession;
import com.blockchain.front.service.trading.TradingManage;
import com.blockchain.front.service.trading.entity.ZhEntity;
import com.blockchain.front.servlets.trading.AbstractTradingServlet;
import com.blockchain.front.util.JsonUtil;
import com.blockchain.util.parser.IntegerParser;

public class UserZh extends AbstractTradingServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void processPost(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		PrintWriter out = response.getWriter();
		int scid = IntegerParser.parse(request.getParameter("scid"));
		Map<String,Object> result  = new HashMap<>();
		result.put("num", "0");
		result.put("msg", "");
		TradingManage tradingManage = serviceSession.getService(TradingManage.class);
		ZhEntity zh=tradingManage.getZh(scid);
		if (scid <= 0) {
			result.put("msg", "市场不存在。");
			out.write(JsonUtil.GsonString(result));
			return;
		}
		if (zh != null) {
			result.put("num", "1");
			result.put("msg", zh);
			out.write(JsonUtil.GsonString(result));
			return;
		}

	}
}
